<!DOCTYPE html>
<html lang="en">
<script src="../js/jquery/jquery-3.5.1.min.js"></script>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--<a href="json/getJson">获取Json字符串</a>-->
<button id="btn" value="getJson">json</button>
<h3 id="js">异步请求</h3>

<h6>--------------------------------------------------------</h6><br/>

<button id="btn2" value="jackson">jackson</button>
<h3 id="jack">uname:jackson</h3>
</body>
<script>
    $(function () {
        $("#btn").click(function(){
            $.get("http://localhost:8080/springmvc_1/json/getJson", {}, function (data) {
                $("#js").html('uname:'+data.uname+"--age"+data.age+"--birthday:"+data.birthday);
            })
        })


        $("#btn2").click(function () {
            //get请求的请求参数不会封装为json格式，所以处理请求的方法中@RequestBody User user 无法将参数封装到user对象，会导致Required 请求参数缺失
            $.post("http://localhost:8080/springmvc_1/json/check",{uname:'jackson',age:10},function (data) {
                $("#jack").html('uname:'+data.uname+"--age:"+data.age+"--birthday:"+data.birthday);
            })
        })
    })
</script>
</html>